<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>">
<meta charset="UTF-8">
<link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
<script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
	<script>
		//在页面加载完取得焦点
		$(function () {


			//取得焦点 focus
		$("#loginAct").focus();

		//未登录按钮绑定事件，执行验证登录操作


			//click 鼠标左键事件
		$("#submitBtn").click(function () {

			//alert("点击登录");
			login()

		});





		$(window).keydown(function (event) {
			//如果码值等于13 是回车键
			if (event.keyCode==13){
				//alert("验证登录")

				login();
			}

		})

		});




		//验证登陆操作
		function login() {
			//取得账号和密码
			//关于取值问题
			//去空格
			var loginAct = $.trim($("#loginAct").val());
			var loginPwd = $.trim($("#loginPwd").val());
			if (loginAct=="" || loginPwd==""){
				$("#msg").html("账号或密码不能为空")

				return false
			}


			var flag="";
			if ($("#flag").prop("checked")) {

				flag="a"

			}

			$.ajax({

				url:"settings/user/login.do",               //请求路径
				data:{
					"loginAct":loginAct,
					"loginPwd":loginPwd,
					"flag"	  :flag,

				},              //请求参数
				type:"post",                //请求方式 get post
				dataType:"",            //对应后台响应得处理方式 text json
				success :function (data) {      //响应后台回来得数据

					/*

						data
							{success:true/false,msg:?}

					 */
				if (data.success) {

					//登录成功跳转到工作台初始页
					//后台请求转发

					window.location.href="workbench/toIndex.do"

				}else {
					//登录失败局部刷新错误消息
					$("#msg").html(data.msg)

				}



				}

					}

			)



		}




	</script>
</head>
<body>
	<div style="position: absolute; top: 0px; left: 0px; width: 60%;">
		<img src="image/IMG_7114.JPG" style="width: 100%; height: 90%; position: relative; top: 50px;">
	</div>
	<div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
		<div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">&copy;2019&nbsp;动力节点</span></div>
	</div>
	
	<div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
		<div style="position: absolute; top: 0px; right: 60px;">
			<div class="page-header">
				<h1>登录</h1>
			</div>
			<form action="workbench/index.html" class="form-horizontal" role="form">
				<div class="form-group form-group-lg">
					<div style="width: 350px;">
						<input class="form-control" type="text" placeholder="用户名" id="loginAct">
					</div>
					<div style="width: 350px; position: relative;top: 20px;">
						<input class="form-control" type="password" placeholder="密码" id="loginPwd">
					</div>
					<div class="checkbox"  style="position: relative;top: 30px; left: 10px;">
						<label>
							<input type="checkbox" id="flag"> 十天内免登录
						</label>
						&nbsp;&nbsp;
						<span id="msg" style="color: red"></span>
					</div>

					<!--
					button type="submit"  传统请求 全局刷新
					button type="button"  	ajax请求	 局部刷新 一绑定事件
					-->
					<button type="button" id="submitBtn" class="btn btn-primary btn-lg btn-block"  style="width: 350px;
					position:
					relative;top: 45px;">登录</button>
				</div>
			</form>
		</div>
	</div>
</body>
</html>